package com.itheima.config;

import com.itheima.interceptor.MyLoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyInterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private MyLoginInterceptor myLoginInterceptor;
    //这个方法是专门用于注册我们自定义拦截器的方法
    //InterceptorRegistry  注册对象
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册的同时指定要拦截的路径和要忽略的路径
        //  /**代表任意路径且任意层级  /*  代表任意一层路径
        registry.addInterceptor(myLoginInterceptor).addPathPatterns("/**")
                .excludePathPatterns("/login");
    }
}
